﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Squog_1._1.Managers;

namespace Squog_1._1.Menu
{
    public abstract class Window
    {
        protected Texture2D Background;
        protected SpriteFont MenuFont;
        protected SpriteFont TextFont;

        private Vector2 windowscale;
        public Vector2 WindowScale { get { return windowscale; } private set { windowscale = value; } }
        private Vector2 windowposition;
        public Vector2 WindowPosition { get { return windowposition; } private set { windowposition = value; } }

        private SpriteBatch spritebatch;
        protected SpriteBatch WindowsSpriteBatch { get { return spritebatch; } private set { spritebatch = value; } }

        protected Window(Vector2 WindowScale, Vector2 WindowPosition)
        {
            this.WindowScale = WindowScale;
            this.WindowPosition = WindowPosition;

            WindowsSpriteBatch = WindowManager.GenerateNewSpriteBatch();
        }

        public virtual void LoadContent(ContentManager Content)
        {
            MenuFont = Content.Load<SpriteFont>(@"Menu\MainMenuFont");
            TextFont = Content.Load<SpriteFont>(@"Menu\TextFont");
        }

        public virtual void Update(GameTime gameTime) { }

        public virtual void Draw(GameTime gameTime)
        {
            if (Background != null)
            {
                //TODO: Dont create grabage
                Rectangle BGRectangle = new Rectangle((int)WindowPosition.X, (int)WindowPosition.Y, (int)(WindowManager.WindowWidth * WindowScale.X), (int)(WindowManager.WindowHeight * WindowScale.Y));
                WindowsSpriteBatch.Draw(Background, BGRectangle, Color.White);
            }
        }

        public void SpriteBatchBegin()
        {
            WindowsSpriteBatch.Begin();
        }

        public void SpriteBatchEnd()
        {
            WindowsSpriteBatch.End();
        }


    }
}
